<template>
	<view class="bottom-buttons">
		<view class="bottom-view left-view" v-if="showCancel">
			<u-button :custom-style="cancelStyle" @click="handleClickCancel">
				<view class="confirm-view">
					<image :src="leftIcon" mode="" v-if="leftIcon" class="icon-view"></image>
					<text class="button-text">{{ cancelText }}</text>
				</view>
			</u-button>
		</view>
		<view class="bottom-view right-view">
			<u-button :type="customConFirm.type" :hairline="false" :custom-style="customConFirm"
				@click="handleClickSure" :disabled="disabled" :loading="loading">
				<view class="confirm-view">
					<image :src="rightIcon" mode="" v-if="rightIcon" class="icon-view"></image>
					<text class="button-text">{{ confirmText }}</text>
				</view>
			</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			disabled: {
				type: Boolean,
				default: false
			},
			loading: {
				type: Boolean,
				default: false
			},
			showCancel: {
				type: Boolean,
				default: true
			},
			cancelText: {
				type: String,
				default: '取消'
			},

			confirmText: {
				type: String,
				default: '保存'
			},
			customCancel: {
				type: Object,
				default: () => {}
			},
			leftIcon: {
				type: String,
				default: ''
			},
			rightIcon: {
				type: String,
				default: ''
			},
		},
		data() {
			return {};
		},
		computed: {
			cancelStyle() {
				return {
					color: '#5ACEE0',
					height: '88rpx',
					'border-radius': '44rpx',
					'border-color': '#5ACEE0',
					// width: '200rpx',
					...this.customCancel
				}
			},
			customConFirm() {
				return {
					// type: this.disabled ? '' : 'warning',
					color: '#FFFFFF',
					// 'background-color': this.disabled ? '#FFC28E' : '#DF7922',
					background: "linear-gradient( 315deg, #43D9F0 0%, #5CE5D5 100%)",
					height: '88rpx',
					'border-radius': '44rpx'
				};
			}
		},
		methods: {
			handleClickCancel() {
				this.$emit('cancel');
			},
			handleClickSure() {
				this.$emit('confirm');
			}
		}
	};
</script>

<style lang="scss" scoped>
	.bottom-buttons {
		margin: 16rpx 24rpx 36rpx 24rpx;
		display: flex;
		align-items: center;
		padding: 0 32rpx;

		.bottom-view {
			flex: 1;
		}
		.confirm-view{
			display: flex;
			align-items: center;
			justify-content: center;
			.button-text{
				white-space:nowrap;
				font-size: 14px;
			}
		}
		.icon-view{
			flex-shrink: 0;
			width: 38rpx;
			height: 38rpx;
			margin-right: 10rpx;
		}

		.left-view {
			margin-right: 32rpx;

			.skip-view {
				// color: #fc524d;
				height: 88rpx;
				line-height: 88rpx;
				font-weight: bold;
				font-size: 14px;
			}
		}

		.right-view {
			flex: 1;

			.confirm-view {
				color: #ffffff;
				height: 88rpx;
				// line-height: 88rpx;
				// font-weight: bold;
				font-size: 14px;
			}
		}
	}
</style>